package com.systemdevelopment.mainproject.Model;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class SuperAdmin extends Admin{
    static final String Authority="SUPERADMIN";//权限
    public String getAuthority()
    {
        return Authority;
    }
    public static SuperAdmin GetSuperAdminFromDBByAccount(String Account) {
        SuperAdmin admin = new SuperAdmin();
        try {
            Connection conn = DataBaseManager.build_conn();
            String Sql = "select * from LIB.ADMINISTRATOR where ACCOUNT = " + "'" + Account + "'";

            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery(Sql);

            if (rs.next()) {
                String account = rs.getString("ACCOUNT");
                String password = rs.getString("PASSWORD");
                admin.setAccount(account);
                admin.setPassword(password);
                return admin;

            } else{
                //没找到此账户，异常处理
                return null;
            }
        }catch (SQLException Se) {
            Se.printStackTrace();
        }
        return null;

    }

}
